#ifndef QuestionItem_H
#define QuestionItem_H

#include "Item.h"
#include "../core/src/AssetManager.h"

namespace Xps
{
	namespace Tree
	{
		class QuestionItem : public Item
		{
		public:
			/*QLabel te;
			QWidget bla;*/
			int questionid;
			QString question;
			XpsAssets::AssetManager* am;

			QuestionItem(int qid, XpsAssets::AssetManager* am) : Item(XpsAssets::TreeNode::QUESTION)
			{
				this->am = am;

				questionid = qid;
				color = Qt::lightGray;
				font.setPointSize(26);
				textFlags = Qt::AlignCenter;
				size.setWidth(32);
				size.setHeight(32);
				pen.setColor(Qt::darkGray);
			}

			void QuestionItem::updateDetails()
			{
				question = am->getQuestion(questionid)->text();
			}

			void QuestionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
			{
				painter->setClipRect(option->exposedRect);

				if (option->state & QStyle::State_MouseOver)
				{
					paintHoverRect(painter);
				}
				if (option->state & QStyle::State_Selected)
				{
					paintSelectionRect(painter);
				}
				
				QPixmap question(":/rs/images/questionitem.png");
				painter->drawPixmap(QRect(0, 0, size.width(), size.height()), question, QRect(0, 0, 64, 64));
				
				Item::paint(painter, option, widget);
			}
		};
	}
}

#endif